import ajax from "./ajax";
// 获取首页轮播图
async function get_lunbo() {
  let data = await ajax(
    `home/banner?type=m&local_code=10&limit=6&order=weight`
  );
  // console.log("首页轮播图数据：", data);
  return data;
}

// 获取首页大触直播
async function get_broadcast() {
  let data = await ajax(`daniu?link=paging&live=3&is_live=1&limit=3&page=1`);
  // console.log("大触直播数据：", data);
  return data;
}

// 获取首页热门教程
async function get_hot_course() {
  let data = await ajax(`home/series`);
  console.log("热门教程数据：", data);
  return data;
}

// 获取首页图文教程
async function get_imgtext_course() {
  let data = await ajax(`home/graphic-tutorials`);
  // console.log("图文教程数据：", data);
  return data;
}

// 获取推荐资讯数据
async function get_command_info() {
  let data = await ajax(`home/news`);
  // console.log("推荐资讯数据：", data);
  return data;
}

// 获取教程页面的分类
async function get_course_cates() {
  let data = await ajax(`course-group-list?course_fields=1`);
  // console.log("教程页面的分类数据：", data);
  return data;
}

// 获取教程轮播图
async function get_course_lunbo() {
  let data = await ajax(
    `series/banners?type=m&limit=6&order=weight&position=3&locality=0`
  );
  console.log("教程轮播图数据：", data);
  return data;
}

// 获取教程精选分类中精选教程
async function get_good_course() {
  let data = await ajax(`course/video?is_recommend=Y&limit=8&not_ids=`);
  console.log("精选教程数据：", data);
  return data;
}

// 获取教程精选分类中最新教程
async function get_new_course() {
  let data = await ajax(
    `course/video?type=1&limit=8&not_ids=1273,1143,529,1281,1210,1413,1233,1456`
  );
  console.log("最新教程数据：", data);
  return data;
}

// 获取教程精选分类中限时免费教程
async function get_free_course() {
  let data = await ajax(
    `course/video?is_free=Y&limit=8&not_ids=1273,1143,529,1281,1210,1413,1233,1456,1473,1471,1463,1462,1461,1460,1459,1458`
  );
  console.log("限时免费教程数据：", data);
  return data;
}

// 获取分类详情信息
async function get_cate_detail() {
  let data = await ajax(`course-group-list`);
  // console.log("获取分类详情信息数据：", data);
  return data;
}

// 获取分类页面的主题数据
async function get_cate_theme(id) {
  let data = await ajax(`course-fields-show/${id}?not_group=1`);
  console.log("根据id分类页面的主题数据数据：", data);
  return data;
}

// 获取分类课程详情
async function get_video_detail(
  type,
  page,
  course_fields_ids,
  course_subjects_ids,
  course_tools_ids,
  level,
  title,
) {
  let data = await ajax(
    `course/video?${type ? `type=${type}` : ""}${page ? `&page=${page}` : ""}${
      course_fields_ids ? `&course_fields_ids=${course_fields_ids}` : ""
    }${
      course_subjects_ids.length > 0
        ? `&course_subjects_ids=${course_subjects_ids}`
        : ""
    }${
      course_tools_ids.length > 0 ? `&course_tools_ids=${course_tools_ids}` : ""
    }${level ? `&level=${level}` : ""}${title ? `&title=${title}` : ""}`
  );
  console.log("获取分类课程详情数据：", data);
  return data;
}

// 分类页面搜索框
async function get_cate_search(type,title,page){
  let data=await ajax(`course/video?type=${type}&title=${title}&page=${page}`);
  console.log("分类页面搜索框数据：", data);
  return data;
}
export {
  get_lunbo,
  get_broadcast,
  get_hot_course,
  get_imgtext_course,
  get_command_info,
  get_course_cates,
  get_course_lunbo,
  get_good_course,
  get_new_course,
  get_free_course,
  get_cate_detail,
  get_video_detail,
  get_cate_theme,
  get_cate_search,
};
